package com.zoffy.catdiarybackend.model.vo;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Permissions {
    private Boolean collaborative;
    private List<Integer> collaborators;
    public static Permissions str2obj(String jsonString){
        JSONObject jsonObject = JSONObject.parseObject(jsonString);
        Permissions permissions=new Permissions();
        boolean collaborative =(boolean) jsonObject.get("collaborative");
        List<Integer> collaborators = JSONArray.parseArray(jsonObject.getString("collaborators"), Integer.class);
        permissions.setCollaborative(collaborative);
        permissions.setCollaborators(collaborators);
        return permissions;
    }
}
